//获取应用实例
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    yijian: '',
  },
  bindInput: function (event) {
    this.setData({
      yijian: event.detail.value,
    })
  },
  submit: function (event) {
    if (this.data.yijian == '') {
      wx.showToast({
        title: '请输入意见！',
        image: '../../images/img_jinggao.png',
        duration: 1000
      })
    }else{
      //访问接口
      wx.request({
        url: app.globalData.ServiceUrl + 'Suggestion/SaveSuggestion', //接口地址
        method: 'POST',
        data: {
          ValidateData: app.globalData.ValidateData,
          paras: {
            userGuid: app.globalData.OPEN_ID,
            suggestion: this.data.yijian,
            userName: app.globalData.nickname
          }
        },
        header: {
          'content-type': 'application/json' // 默认值
        },
        success: function (res) {
          console.log(res.data)
          if (res.data.BusinessInfo.Code == 1 && res.data.ReturnInfo.Code == 1) {
            wx.showToast({
              title: '意见提交成功',
              icon: 'success',
              duration: 2000,
              complete: function () {
                //上传成功，关闭页面
                wx.navigateBack({})
              } //接口调用结束的回调函数  
            })

          } else {
            wx.showToast({
              title: '意见提交失败！',
              image: '../../images/img_jinggao.png',
              duration: 1000
            })
          }
        }
      })


     
    }
  },
  
})